﻿using System.Web.Mvc;
using System.Web.Routing;
using Icms.Infra;
using Icms.Resources;
using Omu.Awesome.Mvc;

namespace Icms.WebUI
{
    public class Bootstrapper
    {
        public static void Bootstrap()
        {
            RouteConfigurator.RegisterRoutes(RouteTable.Routes);
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(IoC.Container));
            WindsorConfigurator.Configure();
            ModelMetadataProviders.Current = new AwesomeModelMetadataProvider();

            Settings.Confirm.NoText = "No";
            Settings.PopupForm.OkText = "Submit";
            Settings.Lookup.Interactive = true;
            Settings.PopupForm.ClientSideValidation = false;
            Settings.GetText = AwesomeMui.GetTranslate;
        }
    }

    public static class AwesomeMui
    {
        public static string GetTranslate(string type, string key)
        {
            if (type == "Confirm" && key == "Title") return Mui.Confirm;
            if (type == "PopupForm" && key == "Title") return "";
            if (type == "Lookup" && key == "Title") return "";
            if (type == "PopupForm" && key == "Ok") return Mui.Save;
            switch (key)
            {
                case "Cancel": return Mui.Cancel;
                case "Yes": return Mui.Yes;
                case "No": return Mui.No;
                case "More": return Mui.More;
            }
            return null;
        }
    }
}